<template>
    <el-form :model="ruleForm" :rules="rules" class="demo-ruleForm" ref="ruleForm">
        <!--需要根据拖动的位置显示 行坐标，列坐标，数据需要组装为2维数组，每列个数有可能不一致-->
        <el-row v-for="data in fieldsList">
            <el-col :span="24/data.length" v-for="sdata in data">
                <el-form-item :label="sdata.labelName" :required="sdata.isEmpty==1" >
                    <el-button v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                               v-if="sdata.dataType=='button'" >{{sdata.labelName}}</el-button>
                    <el-autocomplete v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                     v-if="sdata.dataType=='autocomplete'"  clearable/>
                    <el-cascader v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                 v-if="sdata.dataType=='cascader'"  clearable/>
                    <el-checkbox v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                 v-if="sdata.dataType=='checkbox'"/>
                    <el-color-picker v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                     v-if="sdata.dataType=='color-picker'"  clearable/>
                    <el-date-picker v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                    v-if="sdata.dataType=='date-picker'"  clearable/>
                    <el-date-picker v-model="ruleForm[sdata.fieldName]" type="datetime"
                                    :placeholder="sdata.placeholder" v-if="sdata.dataType=='datetime-picker'"  clearable/>
                    <el-input v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                              v-if="sdata.dataType=='input'"  clearable/>
                    <el-input-number v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                     v-if="sdata.dataType=='input-number'"  clearable/>
                    <el-radio v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                              v-if="sdata.dataType=='radio'"/>
                    <el-rate v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                             v-if="sdata.dataType=='rate'"/>
                    <el-select v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                               v-if="sdata.dataType=='select'"  clearable filterable/>
                    <el-slider v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                               v-if="sdata.dataType=='slider'"/>
                    <el-switch v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                               v-if="sdata.dataType=='switch'"/>
                    <el-time-picker v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                    v-if="sdata.dataType=='time-picker'"  clearable/>
                    <el-time-select v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                    v-if="sdata.dataType=='time-select'"  clearable/>
                    <el-transfer v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                                 v-if="sdata.dataType=='transfer'"/>
                    <el-upload v-model="ruleForm[sdata.fieldName]" :placeholder="sdata.placeholder"
                               v-if="sdata.dataType=='upload'"/>
                </el-form-item>
            </el-col>
        </el-row>
    </el-form>
</template>

<script>
    export default {
        name: "DynamicFormFields",
        data() {
            return {
                ruleForm: {},
                rules: {}
            }
        },
        props: {
            fieldsList: {
                type: Object,
                required: true
            },
            formInfo: {
                type: Object,
                required: true
            }
        }
    }
</script>

<style scoped>

</style>